package cn.roylion.resilience4j.core;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.HashMap;
import java.util.Map;

/**
 * @author genxin.liu
 * @since 2022/8/3 8:46
 */
@Data
@ConfigurationProperties(prefix = "resilience4j.ratelimiter")
public class Resilience4JRateLimiterProperties {

    /**
     * 限流器配置
     */
    private Map<String, Resilience4JRateLimiter.Config> configs = new HashMap<>();

    /**
     * 缓存配置
     */
    private CacheConfig cache = new CacheConfig();

    @Data
    public static class CacheConfig {

        /**
         * 初始容量
         */
        private Integer initialCapacity = 128;

        /**
         * 最大容量
         */
        private Long maximumSize = 1024L;

        /**
         * 访问后过期时长，单位：分钟
         */
        private Long expireAfterAccess = 1L;
    }
}
